package zhongbo.java.air.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.Topic;
import org.springframework.stereotype.Component;
import zhongbo.java.air.listener.RedisSubscribeLogChannelListener;

@Configuration
@Slf4j
public class RedisListenerConfig {
    public static final String INST_FLIGHT_PATH = "live_flight_path_[lgh]";

    @Autowired
    public void configListener(RedisMessageListenerContainer listenerContainer,
                               RedisSubscribeLogChannelListener logChannelListener) {
        log.info("配置redis监听器，监听频道: {}", INST_FLIGHT_PATH);
        Topic logTopic = new PatternTopic(INST_FLIGHT_PATH);
        listenerContainer.addMessageListener(logChannelListener, logTopic);
    }
}